# Verifies that llvm-bolt prints correct loop information.

RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown \
RUN:   %p/Inputs/loop_nest.s -o %t.o
RUN: link_fdata %p/Inputs/loop_nest.s %t.o %t.fdata --nmtool llvm-nm
RUN: llvm-strip --strip-unneeded %t.o
RUN: %clang %cflags -no-pie %t.o -o %t.exe -Wl,-q

RUN: llvm-bolt %t.exe -o %t --data=%t.fdata \
RUN:   --print-cfg --print-loops --sequential-disassembly --lite=0 \
RUN:   2>&1 | FileCheck %s

CHECK:      Binary Function "main{{.*}}" after building cfg
CHECK:      Loop Info for Function "main{{.*}}"
CHECK:      Outer loop header: .Ltmp[[#MAIN_OUTER_HDR:]]
CHECK-NEXT: Loop basic blocks: .Ltmp[[#MAIN_OUTER_HDR]], .Ltmp[[#]]

CHECK:      Binary Function "foo" after building cfg
CHECK:      Loop Info for Function "foo"
CHECK:      Outer loop header: .Ltmp[[#FOO_OUTER_HDR:]]
CHECK-NEXT: Loop basic blocks: .Ltmp[[#FOO_OUTER_HDR]], .Ltmp[[#]], .LFT[[#]], .Ltmp[[#]], .Ltmp[[#FOO_INNER_HDR:]], .Ltmp[[#]], .Ltmp[[#FOO_INNER_BB:]]
CHECK:      Nested loop header: .Ltmp[[#FOO_INNER_HDR]]
CHECK-NEXT: Loop basic blocks: .Ltmp[[#FOO_INNER_HDR]], .Ltmp[[#FOO_INNER_BB]]
